package com.googlecode.rotools.app;

import java.io.File;
import java.sql.SQLException;

import com.googlecode.rotools.rodb.RODB;
import com.googlecode.rotools.rodb.RODBFactory;

public class InitializeDB extends Task<RODB>{
	private File directory;
	private RODB db;
	
	public void run() {
		try{
			db = null;
			Context context = getContext();
			directory = context.getDirectory();
			directory.mkdirs();
			
			RODBFactory rodbFactory = new RODBFactory();
			db = rodbFactory.getRODB(directory.getAbsolutePath() + "/rodb", true);
			
		} catch (SQLException e) {
			e.printStackTrace();
			
		}finally{
			setResult(db);
			
		}
	}
}
